﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Xyz.DataObjects;
using Xyz.DataObjects.Interfaces;
using Xyz.BusinessObjects;
using Xyz.Service.DataTransferObjects;
using Xyz.Service.ServiceContracts;

namespace Xyz.Service
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class AdministratorService : IAdministratorService
    {
        public static readonly IAdministratorDao AdministratorDao = DataAccess.AdministratorDao;

        public void CreateAdministrator(AdministratorDTO administrator)
        {
            Administrator admin = Mapper.FromDto(administrator);

            if (admin.Validate())
            {
                AdministratorDao.CreateAdministrator(admin);
            }
        }

        public AdministratorDTO GetAdministrator(string loginId, string password)
        {
            Administrator admin = AdministratorDao.GetAdministrator(loginId, password);
            if (admin != null)
                return Mapper.ToDto(admin);
            else
                return null;
        }
    }
}
